package ags;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.List;

import ags.muse.base.BotBase;
import ags.muse.gun.Hypothermia;
import ags.muse.movement.*;
import ags.muse.radar.*;
import ags.muse.recon.*;

import robocode.Event;

public class Glacier extends BotBase {

	private RobotList robots;
	private MeleeRadar radar;
	private EnemyFiring efiring;
	private CloakedEngine movement;
	private Hypothermia gun;
	
	@Override
	public void _onPaint(Graphics2D g) {/*
        movement.paint(g);
        
        g.setColor(Color.green);
        for (EnemyRobot r : robots.getEnemies()) {
        	double rad = r.getClosestDist();
        	AbsolutePoint p = r.getLocation();
        	g.drawOval((int)(p.x-rad), (int)(p.y-rad), (int)(rad*2), (int)(rad*2));
        }
        
        efiring.paint(g);*/
	    g.setColor(Color.green);
        for (EnemyRobot r : robots.getEnemies()) {
            g.drawRect((int)(r.getLocation().x-20+0.5), (int)(r.getLocation().y-20+0.5), 40, 40);
        }
        
        gun.paintTest(g);
	}

	@Override
	public void init() {
		robots = new RobotList(getRules());
		efiring = new EnemyFiring(getRules(), robots);
		radar = new MeleeRadar(getRules(), robots);
		movement = new CloakedEngine(getRules(), robots, efiring);
		gun = new Hypothermia(getRules(), robots);
		
		this.setColors(Color.white, Color.white, Color.white, Color.white);
	}

	@Override
	public void runTick(List<Event> events) {
        robots.handleEvents(events);
        try {
            efiring.update();
        } catch (Exception e) {
        	e.printStackTrace();
        }
        
        if (robots.haveFoundAll()) {
          movement.run(getMovementActor());
          gun.run(getGunActor());
        }
        radar.run(getRadarActor(), getGunActor(), getMovementActor());
	}
}
